home *** CD-ROM | disk | FTP | other *** search
-
-
- 21: SCREEN COMPACTION 276
- ---------------------------
-
-
- SPACK (screen compaction)
-
- SPACK s TO n [tx,ty,bx,by]
-
- The SPACK command packs screen s into memory bank n. Everything about
- the current image is saved, including its mode, screen size, offset and
- display position. This allows you to recreate your screen in exactly
- its original state.
-
- s is the number of the screen which contains yur image. n holds the
- number of a memory bank from 1-16. If this bank doesn't currently
- exist, it will be reserved for you automatically. Your new bank will be
- stored in FAST memory if it's available, and will be saved along with
- our Basic program. After you've called this function, the size of your
- screen can be found using LENGTH. Example:
-
- F$=FSEL$("*","","Load a picture")
- Load Iff F$,0
- Spack 0 To 1
- Print "The length of your new bank is ";Length(1);" Bytes"
- Wait Key
- Screen Close 0
- UnPack 1 To 0 : Rem recreate compacted screen
-
- You don't, of course have to compact an entire screen with this
- instruction. The optional parameters let you compress any rectangular
- section of the display you like.
-
- tx,ty now hold the coordinates of the top left corner of this region.
- bx,by set the position of the bottom right corner. All x coordinates
- are rounded to the nearest 8 pixel boundary.
-
- Note that in order to achieve the maximum memory reduction, SPACK
- will attempt to compact your image using several different strategies.
- It will then compress your image using the method which consumes the
- least amount of memory. One side effect of this efficiency, is that it
- usually takes around 6 secs to compress one of your images. This is 277
- hardly a disadvantage however, as normally the compaction is only
- required when you are writing your programs.
-
- Since each image can be unpacked on the screen in less than a second,
- there's no risk of interference with the speed of your games. It speeds
- is of the essence though, you may wish to use the CBLOCK system
- instead. See the section on Background Graphics for more details.
-
- Incidentally, if you compare the compacted size of your files with
- their original length on the disc, you may be mislead into
- underestimating the size of the memory reduction. It's important to
- realize that the vast majority of these files have ALREADY BEEN
- COMPESSED using the standard IFF compaction routines. So it's rather
- surprising that AMOS can reduce them by a further 20 % !
-
- Compacted screens are perfect for the titles and hi-score tables
- required in an arcade game, as they allow you to introduce snazzy
- screen effects without consuming enormous quantities of memory. They
- can also be incorporated directly into RPGs and Adventures.
-
-
-
- PACK (pack a screen)
-
- PACK s TO n [tx,ty,bx,by]
-
- Compresses screen s into bank number n. Unlike the previous SPACK
- command, only the image data is compressed. So your compacted screen
- must always be unpacked directly into an existing screen.
-
- Because of the way images are decompressed, there will be a
- noticeable shimmer effect unless you've previously double buffered your
- screens. Try to avoid using PACK with single buffered screens. It's
- much more sensible to call the SPACK system for this purpose.
-
- If the optional coordinates are included, only a section of the image
- will be compressed.
-
- Since PACK is fully compatible with the standard AUTOBACK system,
- it's easy to combine compacted images with moving screens. If you are
- using Autoback 2 mode, you'll even be able to unpack your images
- BEHIND existing bobs. It's therefore possible to exploit this
- instruction in conjunction with SCREEN OFFSET to create fantastic
- scrolling backgrounds for your games.
-
-
-
- UNPACK (unpack a compacted screen)
-
- Decompresses a screen which has been previously compacted using the
- SPACK or PACK instructions. Each compaction routine has its own
- specifix form of the UNPACK command.
-
- SPACK
- -----
-
- UNPACK b TO s
-
- Opens a screen s and restores the compacted screen into bank b. If this
- screen already exists, it will completely replaced by the new image.
- Once the screen has been unpacked, it will be neatly flicked into view. 278
-
- PACK
- ----
-
- PACKed screens can be unpacked using two separate instructions. These
- take an image from a memory bank, and load it straight into an existing
- screen. WARNING! The destination screen MUST be in exactly the same
- format as your compacted picture, otherwise you'll get an
- "illegal function call" error.
-
- When you unpack your screens, you may notice that the effect is
- slightly messy. That's 'cause the PACK command is only really intended
- for use with the double buffering system. Providing your screen is
- double buffered, you'll get a delightfully smooth result.
-
- UNPACK b
-
- Unpacks the screen at its original position
-
- UNPACK b,x,y
-
- Redraws your image starting at coordinates x,y. If the new image
- doesnt' fit into the current screen, you'll get an error message.
-
-
-
-
-
-
-